﻿using Adnc.Application.Shared.Dtos;
using Adnc.WebApi.Shared;
using Microsoft.AspNetCore.Mvc;
using WYT.Pro.Application.Contracts.Dtos.Group;
using WYT.Pro.Application.Contracts.Dtos.Product;
using WYT.Pro.Application.Contracts.Services;

namespace WYT.Pro.WebApi.Controllers
{
    /// <summary>
    /// 商品分组管理
    /// </summary>
    [Route("pro/[Controller]")]
    [ApiController]
    public class ProductGroupController : AdncControllerBase
    {

        private readonly IProductGroupAppService _productGroupAppService;


        public ProductGroupController(IProductGroupAppService productGroupAppService)
        {
            _productGroupAppService = productGroupAppService;
        }


        /// <summary>
        /// 获取分组信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet("group")]
        public async Task<WYTActionResult<List<GroupDto>>> GetProductGroup([FromQuery] GroupSearchDto input)
        {
            return Success(await _productGroupAppService.GetProductGroup(input));
        }

        /// <summary>
        /// 分页查询商品
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet("page")]
        public async Task<WYTActionResult<PageModelDto<ProductListDto>>> GetProductbyList([FromQuery] GroupProductPagedSearchDto input)
        {
            return Success(await _productGroupAppService.GetProductbyList(input));
        }
    }
}
